<?php
class ATuviCategory extends CActiveRecord{
    public static function model($className = __CLASS__) {
        return parent::model ( $className );
    }


    // goi den bang can ket noi   
    public function tableName() {                  
        return 'c_tuvi_category';
    }

    public function getAllData($type=0){
        $sql = "SELECT * FROM c_tuvi_category ORDER BY id DESC";
        $connect = Yii::app()->db;
        $command = Yii::app()->db->createCommand($sql);
        $rows = $command->queryAll();
        if($type==4){
            foreach($rows as $value){
                $data[$value["id"]] = $value["title"];
            }
        }else{
            $data = $rows;
        }
        return $data;
    }
    public function getDataById($id){
        $sql = "SELECT * FROM c_tuvi_category WHERE id = ".intval($id);
        $connect = Yii::app()->db;
        $command = $connect->createCommand($sql);
        $data = $command->queryRow();

        return $data;
    }
}
